package com.zyx.javademo.juc.threadfactory;

import com.google.common.util.concurrent.ThreadFactoryBuilder;
import org.apache.commons.lang3.concurrent.BasicThreadFactory;

import java.util.concurrent.ThreadFactory;

/**
 * @author Yaxi.Zhang
 * @since 2021/7/12 10:06
 * desc: 生产中常用的创建ThreadFactory实例的方式
 *  spring的CustomizableThreadFactory
 *  guava的ThreadFactoryBuilder链式方法。这个最好用
 *  commons-lang3的BasicThreadFactory
 */
public class ThreadFactoryDemo {
    /**
     * 导包: guava
     * 所在类: import com.google.common.util.concurrent.ThreadFactoryBuilder
     */
    private static final ThreadFactory NAMED_THREAD_FACTORY = new ThreadFactoryBuilder()
            .setNameFormat("demo-pool-%d").build();

    /**
     * 导包commons-lang3
     * import org.apache.commons.lang3.concurrent.BasicThreadFactory
     */
    private static final ThreadFactory NAMED_BASIC_THREAD_FACTORY = new BasicThreadFactory
            .Builder().namingPattern("demo-pool-%d").build();
}
